//
//  ImageUtility.h
//  EsGUtils
//
//  Created by apple on 14-11-13.
//  Copyright (c) 2014年 ChinaSoftI. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import <Accelerate/Accelerate.h>
#import <ImageIO/ImageIO.h>
#import <AssetsLibrary/AssetsLibrary.h>
#import <CoreLocation/CoreLocation.h>

@interface ImageUtility : NSObject


//居中裁减正方形图片，发布图片使用 已经不用了 因为支持长图发送
+ (UIImage*) createRectangleImageInCenter:(UIImage *)image withWidth:(int)width;

//缩放图片到width＊width 保持比例不变 保持scale不变。用于从网站上下载图片重采样和生成新的合适大小的图片，并自动适配scale
+ (UIImage*)createImageKeepAspect:(UIImage *)image maxWidthOrHeight:(float)maxWidthOrHeight;

//用于上传到服务器的图片，指定分辨率，保持aspect，scale＝1
+ (UIImage*)createImageKeepAspectForUpload:(UIImage *)image fillWithWidth:(float)maxWidth;

+(int)createEvenInt:(int)num;

//缩放图片到width＊width 保持比例不变 保持scale不变
+ (UIImage*) createImageAspect:(UIImage *)image fillWithWidth:(float)maxWidth;

//重中间裁减一块图片，发布图片使用
+ (UIImage *)createImageFromRect:(UIImage *)image frame:(CGRect)frame;

//模糊效果
+ (UIImage *)blurryImage:(UIImage *)image boxSize:(int)boxSize;

//最好的模糊效果  毛玻璃效果！！！

//inradius 20
+ (UIImage*)stackBlurWithImage:(UIImage *)image inradius:(NSUInteger)inradius;

+ (UIImage *)normalizeWithImage:(UIImage *)image;

//模糊效果
+ (UIImage *)blurredImageWithRadius:(CGFloat)radius
                              image:(UIImage *)image
                         iterations:(NSUInteger)iterations;

//压缩或者裁剪，使其宽高都小于最大值，不必要保证比例，发布图片使用
+ (UIImage*) saclePublishImage:(UIImage *)image
                  withMaxWidth:(NSInteger) maxWidth
                 withMaxHeight:(NSInteger) maxHeight;



//截图 截取整个view的图片
+ (UIImage *)createImageFromView:(UIView *)theView;

//截图 截取view中间一块的frame的图片
+ (UIImage *)createImageFromView:(UIView *)theView frame:(CGRect)frame;


/// 缩放和旋转照片
/**
 * @param image 原始图像
 * @param maxResolution 最大分辨率
 * @return UIImage 图像
 */
+ (UIImage *)scaleAndRotateImage:(UIImage *)image
          withMaxResolutionWidth:(NSInteger) maxResolutionWidth
           orMaxResolutionHeight:(NSInteger) maxResolutionHeight;

/// 为照片添加边框
/**
 * @param source 原始图像
 * @param borderSize 边框尺寸
 * @return UIImage 图像
 */
+ (UIImage*)imageWithBorderFromImage:(UIImage*)source withBorderSize:(float)borderSize;

/// 为照片指定大小和边缘角度
/**
 * @param source 原始图像
 * @param radius 边缘半径
 * @param desSize 目标尺寸
 * @return UIImage 图像
 */
+ (UIImage*)imageWithRoundedFromImage:(UIImage*)source
                           withRadius: (CGFloat) radius
                        andDesirtSize:(CGSize) desSize;


///图片处理
/**
 *@return 添加文字后的图片
 */
+ (UIImage *) addText:(UIImage *)img text:(NSString *)text1 text:(NSString *)text2;

///图片处理
/**
 *@return 合成后的图片
 */
+ (UIImage *) mergeImage:(UIImage *)imgA withImage:(UIImage *)imgB;

///图片处理
/**
 *@return 合成后的图片
 */
+ (UIImage *) mergeImage:(UIImage *)imgA withLogo: (UIImage *) imgB withText: (NSString *) baseString;

///图片处理
/**
 *@return 合成后的图片
 */
+ (UIImage *) mergeImage: (UIImage *)imgA
                withLogo: (UIImage *) imgB
                withText: (NSString *) baseString
              goodResult: (NSInteger) goodRes
               badResult: (NSInteger) badRes
                   Total: (NSInteger) total;

//+ (UIImage*) createRectangleImageWithBorder:(UIImage *)image;

+ (UIImage *) addImage:(UIImage *)imgA toImage:(UIImage *)imgB;

///添加Exif信息到image
+(NSData *) geoTaggedDataWithLocation:(CLLocation *)location
                                image:(UIImage *)image;
+(NSData *) geoTaggedData:(NSData *)data
             withLocation:(CLLocation *)location
                imageTime:(NSDate *)imageTime;


/**
 *	@brief	对缩略图进行压缩
 *
 *	@param 	dataLength 	图片数据的大小
 *
 *	@return	压缩比例
 */
+(CGFloat)compressionThumbImage:(NSInteger)dataLength;


@end
